Tutorials
Getting started
Chart interface
Web components
Chart internals
Data integration
Customization
Frameworks and bundlers
Mobile development
Plug-ins
Compact Chart
Troubleshooting
Glossary
Reference
JSFiddles

Reference Data Quotefeed

The reference data quotefeed resembles the main chart's quotefeed. The key difference is that the reference data quotefeed is configured to check for and match various datasets that the user requests via the UI.

Creating and Attaching a QuoteFeed

Extend the built-in ReferenceData.Quotefeed class to match quote feed requests with corresponding datasets. The example below, which is a simplified version from SPGIReferenceData.js, checks if CustomMarkerDataset or CustomSeriesDataset is selected as reference data via the UI, then calls the CustomAPIRequest function.

For custom datasets, implement the necessary API request code for quote lookup. Modify the CustomAPIRequest function in chartiq/examples/feeds/SPGIReferenceData.js as needed.

class SPGICustomQuoteFeed extends CIQ.ReferenceData.QuoteFeed {
  requestHandler(request, callback) {
      const dataset = request.dataset;

      if (dataset.is(CustomMarkerDataset)) {
          // Implement your own API Request
          CustomMarkerAPIRequest(request).then((quotes) => {
              callback({ quotes });
          });
      } else if (dataset.is(CustomSeriesDataset)) {
          // Implement your own API Request
          CustomSeriesAPIRequest(request).then((quotes) => {
              callback({ quotes });
          });
      }
  }
}

Built In methods

buildQuery

If your API requires different parameters, you can modify them in the datasets found at chartiq/plugins/referencedata/js/Core/Datasets/.

Below is an example of a buildQuery method from the Consensus.js file. This is where you construct your query to pass to your API. It adds a properties object with a mnemonic property specific to SPGI data. If your API requires different properties, modify the query accordingly.

buildQuery(baseQuery) {
    return {
        ...baseQuery,
        type: "CONSENSUS",
        properties: {
            ...baseQuery.properties,
            mnemonic: "IQ_PRICE_TARGET_CIQ"
        }
    };
}

transformQuote

Similar to the buildQuery method, the transformQuote method processes the API response and formats the data as needed. The example below, found in Consensus.js, checks for a DT field and adds one if it's missing. Adjust this method if necessary to ensure the chart renders data correctly.

transformQuote(response, query) {
        return response.map((quote) => {
            if (!quote.DT) {
                quote.DT =
                    quote.EPS_MEDIAN?.DT ||
                        quote.EPS_CONSENSUS?.DT ||
                        quote.EPS_GUIDANCE?.DT;
            }
            return quote;
        });
    }

Next Steps